<template>
  <div class="friendDetailWrap">
    <div v-if="$route.query.chatCode" class="detailWrap">
      <div class="detailPersonal">
        <div class="detaileHead">
          <span class="detailUserName">
            {{ friendDetail.userName }}
            <i
              :class="[
                'iconfont',
                friendDetail.sex ? 'red iconwoman' : 'blue iconwoman1'
              ]"
            ></i>
          </span>
          <span class="detailUserProfile">{{ friendDetail.userProfile }}</span>
        </div>
        <Header class="headSize" :src="friendDetail.base+friendDetail.headImg"/>
      </div>
      <div class="detailOther">
        <div class="otherItem">
          <label>备注名</label>
          <input type="text" v-model="friendDetail.userRemarks" placeholder="添加备注名">
        </div>
        <div class="otherItem">
          <label>社交号</label>
          <span>{{ friendDetail.chatCode }}</span>
        </div>
        <div class="otherItem">
          <label>地&nbsp&nbsp&nbsp区</label>
          <span>{{ friendDetail.province + friendDetail.city }}</span>
        </div>
      </div>
      <div class="btnBar">
        <button @click="toSendMessage">发消息</button>
      </div>
    </div>
    <div v-if="!$route.query.chatCode"></div>
  </div>
</template>

<script type='text/ecmascript-6'>
import api from "@/api/index.js";
import Header from "../comp/Header.vue";
export default {
  components: {
    Header
  },
  props: {
    friendDetail: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {};
  },
  mounted() { },
  methods: {
    toSendMessage() {
      const params = {
        fromChatCode: JSON.parse(localStorage.userInfo).chatCode,
        toChatCode: this.friendDetail.chatCode
      }
      api.chatAdd(params).then((res) => {
        this.$router.push({ name: 'chat', query: { chatCode: this.friendDetail.chatCode } })
      })
    }
  }
};
</script>

<style lang='scss' scoped>
.friendDetailWrap {
  .detailWrap {
    margin: 100px auto 0;
    width: 400px;
    .detailPersonal {
      $height: 80px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      height: $height;
      border-bottom: 1px solid #e6e6e6;
      padding: 20px 0;
      .detaileHead {
        flex: 1;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        > span {
          display: inline-block;
          flex: 1;
          line-height: $height/2;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .detailUserName {
          font-size: 24px;
          .red {
            color: red;
          }
          .blue {
            color: #4747f3;
          }
        }
        .detailUserProfile {
          color: #999;
          font-size: 14px;
        }
      }
      .headSize {
        width: $height;
        height: 100%;
        flex-shrink: 0;
      }
    }
    .detailOther {
      padding: 20px 0;
      .otherItem {
        padding: 10px 0;
        $size: 14px;
        > label {
          display: inline-block;
          width: 65px;
          font-size: $size;
          color: #999;
        }
        > input {
          font-size: $size;
          border: none;
          outline: none;
        }
        > span {
          font-size: $size;
          color: #333;
        }
      }
    }
    .btnBar {
      padding: 30px;
      text-align: center;
      > button {
        padding: 8px 35px;
        border-radius: 4px;
        border: 1px solid #3baf3d;
        background: #3baf3d;
        color: #fff;
        font-size: 16px;
        cursor: pointer;
        outline: none;
      }
    }
  }
}
</style>